/**
 * Copyright &copy; 2019-2022 <a href="https://gitee.com/rit/zx-pm">zx-pm</a> All rights reserved.
 */
package com.zx.pm.modules.zx.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zx.pm.common.persistence.Page;
import com.zx.pm.common.service.CrudService;
import com.zx.pm.common.utils.StringUtils;
import com.zx.pm.modules.zx.entity.BidBond;
import com.zx.pm.modules.zx.entity.ProSupplier;
import com.zx.pm.modules.zx.dao.BidBondDao;
import com.zx.pm.modules.zx.dao.LzdDao;

/**
 * 投标保证金Service
 * @author forest
 * @version 2019-02-27
 */
@Service
@Transactional(readOnly = true)
public class BidBondService extends CrudService<BidBondDao, BidBond> {

	@Autowired
	private LzdDao lzdDao;
	
	public BidBond get(String id) {
		return super.get(id);
	}
	
	public List<BidBond> findList(BidBond bidBond) {
		return super.findList(bidBond);
	}
	
	public Page<BidBond> findPage(Page<BidBond> page, BidBond bidBond) {
		return super.findPage(page, bidBond);
	}
	
	@Transactional(readOnly = false)
	public void save(BidBond bidBond) {
		if(StringUtils.isBlank(bidBond.getId())) {
			// 更新项目为处理投标保证金阶段
			lzdDao.updateLzdStaut("4", bidBond.getLzdId());
		}
		if (bidBond.getIsNewRecord()){
			bidBond.preInsert();
			dao.insert(bidBond);
		}else{
			bidBond.preUpdate();
			dao.updataStatus(bidBond);
		}
		//super.save(bidBond);
	}
	
	@Transactional(readOnly = false)
	public void updata(BidBond bidBond) {
		
		dao.updataStatus(bidBond);
	}
	
	@Transactional(readOnly = false)
	public void delete(BidBond bidBond) {
		super.delete(bidBond);
	}
	
	public List<ProSupplier> findPayBidBondList(ProSupplier ps){
		return dao.findPayBidBondList(ps);
	}
}